-
Notifications
You must be signed in to change notification settings - Fork 65
p-token: Add unwrap_lamports instruction
#87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
fafdd3e to
8a3de38
Compare
4409253 to
82fa3b5
Compare
joncinque
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! Just the bit on the discriminator. Also, be sure to get someone like @Arrowana to make sure it does what they need.
It looks ok, but should it have a feature similar to close, allowing unwrapping the entire available amount? I see a few use cases for this
|
So would it make more sense to always unwrap the entire amount or have both options? |
both options |
b9cdf7c to
369e713
Compare
@Arrowana PR updated. |
buffalojoec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation lgtm, just left a few comments about the tests!
369e713 to
49ddb17
Compare
buffalojoec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm from my side!
joncinque
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a tiny thing
599d2b1 to
3b92f39
Compare
f300632 to
2cefb4e
Compare
3b92f39 to
20e0ffe
Compare
2cefb4e to
c68c3d3
Compare
The base branch was changed.
20e0ffe to
4db31a0
Compare
Problem
In order to transfer out lamports from native SOL accounts, currently it is necessary to create and close ATAs or token accounts all the time.
Solution
This PR adds a new
unwrap_lamportsinstruction that allows transferring out lamports directly to any destination account. This eliminates the need for creating temporary native token accounts for the recipient.The new instruction uses the discriminator
3945, which is currently unused in Token-2022.The amount to unwrap is specified as an
Option<u64>:None: the entire token balance is unwrapSome(amount): the specified amount is unwrap